package com.mode.mvp.joke;

import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.mode.R;
import com.mode.mvp.base.BaseActivity;
import com.mode.mvp.bean.Joke;

public class JokeActivity extends BaseActivity<JokePresenter, JokeModel> implements JokeContract.JokeView {

    private static final String TAG = "JokeActivity";

    private ProgressBar mLoadingBar;

    @Override
    public void initView() {
        mLoadingBar= findViewById(R.id.pressbar);
        //1.请求网络数据，具体在Model类实现
        mPresenter.requestJoke("1", "10");
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_joke;
    }

    @Override
    public void setJoke(Joke pJoke) {
        //2. 请求到的数据回调，展示在UI上
        Log.d(TAG, "请求数据成功");
        runOnUiThread(() -> Toast.makeText(JokeActivity.this,"请求数据成功",Toast.LENGTH_LONG).show());
    }

    @Override
    public void showLoading() {
        mLoadingBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideLoading() {
        mLoadingBar.setVisibility(View.INVISIBLE);
    }

    @Override
    public void showError() {

    }
}